package com.lagou.runnable;

import com.lagou.bean.ConsumerComponent;

public class ConsumerRunnable implements Runnable {

    private ConsumerComponent consumerComponent;
    private String method;

    public ConsumerRunnable(ConsumerComponent consumerComponent, String method) {
        this.consumerComponent = consumerComponent;
        this.method = method;
    }

    protected void callMethod(){
        if("A".equals(method)){
            consumerComponent.methodA();
        }else if("B".equals(method)){
            consumerComponent.methodB();
        }else{
            consumerComponent.methodC();
        }
    }

    @Override
    public void run() {
        while (true){
            callMethod();
        }
    }
}
